#!/usr/bin/env bash

function _shcp_complete_func () {
  local HOST cur opts cmd
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  now="${COMP_LINE##* }"
  cmd="${COMP_WORDS[COMP_CWORD-1]}"

  HOST=$(shcp --host)
  PARAM_SOR=$(shcp --param-s)
  PARAM_TOR=$(shcp --param-t)
  PARAM_CMD=$(shcp --param-c)

  case "${cmd}" in
  -u)
    ;;
  -c)
    opts="$PARAM_CMD"
    ;;
  shcp)
    opts="$HOST $PARAM_TOR" ;;
  *)
    opts="$PARAM_SOR" ;;
  esac
  COMPREPLY=($(compgen -W "$opts" -- "$cur"))
}
command -v shcp &> /dev/null && complete -o default -F _shcp_complete_func shcp

